using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using HISModels.Entities;

namespace HISModels.Mapping
{
	public class WorkflowStatusMap : EntityTypeConfiguration<WorkflowStatus>
	{
		public WorkflowStatusMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

			// Properties
			this.Property(t => t.Id)
				.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
				
			this.Property(t => t.NameValue)
				.HasMaxLength(50);
				
			// Table & Column Mappings
			this.ToTable("WorkflowStatuses");
			this.Property(t => t.Id).HasColumnName("Id");
			this.Property(t => t.DocumentTypeId).HasColumnName("DocumentTypeId");
			this.Property(t => t.NameValue).HasColumnName("NameValue");

			// Relationships
			this.HasOptional(t => t.RefDocumentType)
				.WithMany(t => t.WorkflowStatuses)
				.HasForeignKey(d => d.DocumentTypeId);
				
		}
	}
}

